/**
 * 本质上就是问[L, R]之间有多少个k满足 A+kM 在区间内
 * 注意L和R有可能是负数，负数取整与整数有区别
 */
#include <bits/stdc++.h>
using namespace std;

#include <bits/extc++.h>
using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#include <bits/stdc++.h>
using namespace std;

char *__abc147, *__xyz258, __ma369[1000000];
#define __hv007() ((__abc147==__xyz258) && (__xyz258=(__abc147=__ma369)+fread(__ma369,1,100000,stdin),__abc147==__xyz258) ? EOF : *__abc147++)

int getInt(){
	int sgn = 1;
	char ch = __hv007();
	while( ch != '-' && ( ch < '0' || ch > '9' ) ) ch = __hv007();
	if ( '-' == ch ) {sgn = 0;ch=__hv007();}
 
	int ret = (int)(ch-'0');
	while( '0' <= (ch=__hv007()) && ch <= '9' ) ret = ret * 10 + (int)(ch-'0');
	return sgn ? ret : -ret;
}

using llt = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

llt A, M, L, R;

llt proc(){
    llt a = (L - A) / M;
    llt b = (R - A) / M;
    if(L - A < 0) a -= 1;
    else if(0 == (L - A) % M) --a;
    if(R - A < 0 and (R - A) % M) b -= 1;
    return b - a;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0);
    int nofkase = 1;
    // cin >> nofkase;
    while(nofkase--){
        cin >> A >> M >> L >> R;
        cout << proc() << "\n";
    }
    return 0;
}